package com.david.SendFileToGateway;

import com.david.SendFileToGateway.config.MultipartSupportConfig;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.awt.*;

/**
 * 发送给网关的工具类
 * 一般网关有两个端口
 *  - 10500 网关接出部分
 *  - 10600 网关接入部分
 */
@FeignClient(name="gatewayOutServer",configuration = MultipartSupportConfig.class)
public interface ImageSender {
    /**
     * 单个文件上传
     * @param multipartFile
     * @param path
     * @param appUser
     * @return
     */
    @RequestMapping(path = "/smartDocument/API/Batch/{path}?_method_=PUT&au={appUser}",headers = {"targetservername=OUTIMAGE-TXBK"},method = RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadUim(@RequestPart(value="files")MultipartFile multipartFile, @PathVariable(value = "path") String path,@PathVariable(value = "appUser") String appUser);


    /**
     * 多个文件上传
     * @param multipartFile
     * @param path
     * @param appUser
     * @return
     */
    @RequestMapping(path = "/smartDocument/API/Batch/{path}?_method_=PUT&au={appUser}",headers = {"targetservername=OUTIMAGE-TXBK"},method = RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadUimBatch(@RequestPart(value="files")MultipartFile[] multipartFile, @PathVariable(value = "path") String path,@PathVariable(value = "appUser") String appUser);

    /**
     * 从影像平台下载文件
     * @param path
     * @param appUser
     * @param password
     * @return
     */
    @GetMapping(path = "/smartDocument/API/Batch/{path}?_method_=PUT&au={appUser}&password={password}",headers = {"targetservername=OUTIMAGE-TXBK"},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Response downloadUim(@PathVariable(value = "path") String path,@PathVariable(value = "appUser") String appUser,@PathVariable(value = "password") String password);
}
